<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8" import="java.util.Map,java.util.List,com.wit.dao.impl.EmployeeDaoImpl,com.wit.po.Clientlevel,com.wit.dao.impl.ClientlevelDaoImpl" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>客户修改</title>
<link href="../style/main.css" rel="stylesheet" type="text/css" />
<link type="text/css" rel="stylesheet" href="../style/style.css" />

<%@ taglib prefix="s" uri="/struts-tags" %>

<style type="text/css">
<!--
@import url("../style/table_css.css");
-->
</style>
<script src="../js/jquery.js"></script>

<script type="text/javascript">
	function getTop(e){ 
		var offset=e.offsetTop; 
		if(e.offsetParent!=null) offset+=getTop(e.offsetParent); 
		return offset; 
	}
	//获取元素的横坐标 
	function getLeft(e){ 
		var offset=e.offsetLeft; 
		if(e.offsetParent!=null) offset+=getLeft(e.offsetParent); 
		return offset; 
	}
	function showTree(e)
	{
		var top = getTop(e);
		var left = getLeft(e);
		var obj = document.getElementById("showTreeDiv");
		if(obj.innerHTML == null || obj.innerHTML.length <= 0)
			obj.innerHTML = "<html><iframe id=\"editIFrame\" frameborder=\"0\" src=\"area_select.jsp\" scrolling=\"yes\" width=\"300\" height=\"300\"></iframe></html>";
		obj.style.left=left;
		obj.style.top = top;
		obj.style.display="";
	}
	function addNewClient()
	{
		var objs = document.getElementsByTagName("input");
		for(i=0;i<objs.length;i++)
		{
			if(objs[i].value == null || objs[i].value.length <= 0)
			{
				alert("客户信息不完整");
				return;
			}
		}
		clientInfoForm.submit();
	}
	function startEdit()
	{
		var obj;
		var i = 0;
		while((obj = document.getElementById("chk"+i)) != null)
		{
			if(obj.checked)
			{
				document.location="contact!startEdit?contactId="+obj.value;
				return;
			}
			i++;
		}
		alert("必须选择一个联系人");
	}
	function removeContact()
	{
		var obj;
		var i = 0,counter = 0,id;
		while((obj = document.getElementById("chk"+i)) != null)
		{
			if(obj.checked)
			{
				id = obj.value;
				counter ++;
			}
			i++;
		}
		if(counter > 1)
			alert("只能删除一个联系人");
		else if(counter == 1)
		{
			var number = searchContactForm.pageNumber.value;
			var size = searchContactForm.pageSize.value;
			document.location = "contact!removeContact?contactId="+id+"&page.pageNumber="+number+"&page.pageSize="+size;
		}
		else
			alert("必须选择一个联系人");
	}
</script>
<%
	Map map = EmployeeDaoImpl.s_GetEmployeeNameList();
	List<Clientlevel> levelList = ClientlevelDaoImpl.s_GetClientlevelList();
	if(levelList == null || levelList.size() == 0)
	{
%>
<script type="text/javascript">
	alert("没有客户级别列表信息，请先添加");
	document.location = "clientlevel_new.jsp";
</script>
<%
		return;
	}
	request.setAttribute("levelList",levelList);
	request.setAttribute("employeeMap",map);
%>
</head>

<body>

<div id="showTreeDiv" style="display:none; position:absolute"></div>

<table width="1000" cellpadding="0" cellspacing="0" class="table">
  <tr>
    <td>
      <table width="100%" cellpadding="0" cellspacing="0" class="table2">
        <tr>
          <td valign="top">

          <div class="mainarea">
            <div class="search" style="padding:10px">
            <s:form name="clientInfoForm" action="clientInfo!updateClient" method="post" theme="simple">
            
            <s:hidden id="clientId" name="client.clientId"></s:hidden>
              <table cellpadding="0" cellspacing="0" width="100%" class="table4">
                  <tr>
                    <th height="25" colspan="4" bgcolor="#BBD2F7" class="title">客户基本信息</th>
                  </tr>
                  <tr>
                    <th width="103"> 客户编号： </th>
                    <td width="347"><s:property value="client.clientId"></s:property></td>
                    <th width="79"> 客户名称： </th>
                    <td width="425"><s:textfield name="client.clientName"></s:textfield>* </td>
                  </tr>
                  <tbody id="tbody_2" >
                    <tr>
                      <th height="19"> 客户类别：</th>
                      <td><s:select name="client.clientType" list="{'个人','团体'}">
                      	  </s:select>
                      </td>
                      <th>性&nbsp;&nbsp;&nbsp;&nbsp;别：</th>
                      <td>
                        <s:select name="client.clientSex" list="{'男','女'}">
                      	</s:select>
                      </td>
                    </tr>
                    
                      <tr>
                    
                      <th >证件类型：</th>
                      <td><s:select name="client.cardType" list="{'身份证','户口本','企业注册号','护照','军人证'}"></s:select></td>
                      <th>生&nbsp;&nbsp;&nbsp;&nbsp;日：</th>
                      <td><s:textfield name="client.clientBorndate" cssStyle="width: 60px">
                      		<s:param name="value">
								<s:date name="client.clientBorndate" format="yyyy-MM-dd"/>
							</s:param>
                      	</s:textfield>
                      </td>
                    </tr>
                      <tr>
                      <th>证件号码：</th>
                      <td><s:textfield name="client.clientIdcard"></s:textfield>* </td>
                      <th>有效日期：</th>
                      <td>
                      	<s:textfield name="client.activeToDate" cssStyle="width: 60px" id="Activedate">
                      		<s:param name="value"><s:date name="client.activeToDate" format="yyyy-MM-dd"/></s:param>
                      	</s:textfield>
                      </td>
                    </tr>
                    
                    
                    
                  
                    <tr>
                      <th>所属地区：</th>
                      <td>
                      	<s:textfield onclick="javascript:showTree(this);" id="areaId" name="client.area.areaId"></s:textfield>
                      </td>
                      <th> 手&nbsp;&nbsp;&nbsp; 机： </th>
                      <td><s:textfield name="client.clientPhone"></s:textfield>* </td>
                    </tr>
                    <tr>
                      <th height="19"> 客户级别：</th>
                      <td>
                   		<s:select name="client.clientlevel.clientlevelId" 
                   					list="#request.levelList" listKey="clientlevelId" listValue="clmemo" >
                   		</s:select>
                      </td>
                      <th>业 务 员： </th>
                      <td>
                      	  <s:select name="client.employee.employeeId" 
                      	  				list="#request.employeeMap" listKey="key" listValue="value">
                      	  </s:select>
                      </td>
                    </tr>
                  </tbody>
                  <tr>
                    <th>行业类型：</th>
                    <td>
						<s:select name="client.clientIndustry" 
									list="{'金融','服务','地产','保险'}">
						</s:select>
                    </td>
                    <th>客户电话：</th>
                    <td><s:textfield name="client.clienttelephone"></s:textfield>* </td>
                  </tr>
                  
                  <tr>
                    <th>详细地址：</th>
                    <td><s:textfield name="client.clientAddress"></s:textfield></td>
                    <th>传&nbsp;&nbsp;&nbsp;&nbsp;真：</th>
                    <td><s:textfield name="client.clientfax"></s:textfield></td>
                  </tr>
                  <tr>
                    <th>电子邮件：</th>
                    <td><s:textfield name="client.clientemail"></s:textfield></td>
                    <th>邮&nbsp;&nbsp;&nbsp;&nbsp;编：</th>
                    <td><s:textfield name="client.clientPostcode"></s:textfield></td>
                  </tr>
                  <tr>
                    <th>开户银行：</th>
                    <td><s:textfield name="client.cbank"></s:textfield></td>
                    <th>银行账号：</th>
                    <td><s:textfield name="client.caccount"></s:textfield></td>
                  </tr>
                   <tr>
                    <th>工作单位：</th>
                    <td><s:textfield name="client.workCompany"></s:textfield></td>
                    <th>婚姻状况：</th>
                    <td> <s:select name="client.maryState" list="{'已婚','未婚','离异'}">
                      	</s:select></td>
                  </tr>	
                   <tr>
                    <th>职位名称：</th>
                    <td><s:textfield name="client.positionName"></s:textfield></td>
                    <th>最高学历：</th>
                    <td> <s:select name="client.eduState" list="{'本科','小学','初中','高中','大专','硕士','博士'}">
                      	</s:select></td>
                  </tr>
                    <tr>
                    <th>国籍：</th>
                    <td><s:textfield name="client.countyBook"></s:textfield></td>
                    <th>户籍：</th>
                    <td><s:textfield name="client.stateBook"></s:textfield></td>
                  </tr>
                    <tr>
                    <th>户籍地址：</th>
                    <td><s:textfield name="client.stateBookadd"></s:textfield></td>
                    <th>登记日期：</th>
                    <td>
                     <s:textfield name="client.addDate" cssStyle="width: 60px" id="djdata">
                      		<s:param name="value"><s:date name="client.addDate" format="yyyy-MM-dd"/></s:param>
                      	</s:textfield>
                    </td>
                  </tr>
                  <tr>
                    <th colspan="4">&nbsp;</th>
                  </tr>
                </table>
                <table cellpadding="0" cellspacing="0" width="100%" class="table5">
                  <tr>
                    <th height="25" colspan="2" bgcolor="#BBD2F7" class="title">附加信息</th>
                  </tr>
                  <tr>
                    <th valign="top"  class="fjxx_left"> 背景资料： </th>
                    <td width="1103">
                    	<s:textarea name="client.cbackg" id="cbackg" cols="45" rows="5" class="fjxx"></s:textarea>
                    </td>
                  </tr>
                  <tbody id="tbody_3" >
                    <tr>
                      <th height="19" valign="top" class="fjxx_left"> 兴趣爱好：</th>
                      <td>
                      	<s:textarea name="client.chobby" id="chobby" cols="45" rows="5" class="fjxx"></s:textarea>
                      </td>
                    </tr>
                    <tr>
                      <th valign="top" class="fjxx_left">备&nbsp;&nbsp;&nbsp;&nbsp;注：</th>
                      <td>
                      	<s:textarea name="client.clmemo" id="clmemo" cols="45" rows="5" class="fjxx"></s:textarea>
                      </td>
                    </tr>
                                        <tr>
                      <th valign="top" class="fjxx_left">风险资料：</th>
                      <td>
                      	<s:textarea name="client.risk" id="risk" cols="45" rows="5" class="fjxx"></s:textarea>
                      </td>
                    </tr>
                  </tbody>
                </table>
                <table width="100%" cellpadding="0" cellspacing="0"class="table3">
                    <tr>
                        <td width="6%" class="title">&nbsp;</td>
                        <td width="5%" ></td>
                        <td width="5%" >&nbsp;</td>
                        <td width="5%" >&nbsp;</td>
                        <td width="5%" >&nbsp;</td>
                        <td width="5%" >&nbsp;</td>
                        <td width="10%" >&nbsp;</td>
                        <td width="5%" >
                        	<a onclick="javascript:addNewClient();" href="javascript:void(0);"><span class="clientinfo_but">保&nbsp;存</span></a>
                        </td>
                        <td width="5%" ><span class="clientinfo_but">取&nbsp;消</span></td>
                        <td width="13%" ></td>  
                        <td width="14%" >&nbsp;</td>
                    </tr>
                </table>
            </s:form>
	<table cellpadding="0" cellspacing="0" width="100%" class="table6">
       <tr>
         <td width="1103" height="30" bgcolor="#BBD2F7" class="title">
         	<a class="on">联系人</a>
         	<a>销售跟进</a>
         	<a>签单记录</a>
         	<a>服务记录</a>
         	<a>特别提醒</a>
         </td>
       </tr>
     </table>
<script type="text/javascript">
$(".table6 a").each(function(i){
	$(this).click(function()
	{
		$(".table6 a").removeClass("on")
		$(this).addClass("on");;
		
	})
})

</script>
                </div>
           <table width="100%" cellpadding="0" cellspacing="0"class="table3">
               <tr>
                   <td width="6%" class="title">&nbsp;</td>
                   <td width="5%">
                   	<a href="clientContact_new.jsp?clientId=<s:property value="client.clientId"/>"><span class="clientinfo_but" >新&nbsp;增</span></a>
                   </td>
                   <td width="5%">
                   	<span class="clientinfo_but" ><a href="javascript:void(0);" onclick="javascript:startEdit();">修&nbsp;改</a></span>
                   </td>
                   <td width="5%">
                   	<a href="javascript:void(0);" onclick="javascript:removeContact();"><img src="../images/btn_del.gif" alt="3" width="50" height="20" /></a>
                   </td>
                   <td width="5%" >
                   </td>
                   <td width="18%" >&nbsp;</td>
                   <td width="5%" ></td>
                   <td width="5%" ></td>
                   <td width="5%" ></td>  
                   <td width="14%" >&nbsp;</td>
              </tr>
            </table>
            <table width="100%" cellpadding="0" cellspacing="1" class="dg_borderstyle">
            <thead>
				<tr>
	                <th width="35"> <input type="checkbox" onclick="docheck()" id="chk_all" /></th>
	                <th width="72">联系人</th>
	                <th width="143">联系人身份证</th>
	                <th width="110">联系人手机</th>
	                <th width="96">联系人电话</th>
	                <th width="96">传真</th>
	                <th width="92">出生日期</th>
	                <th width="175">电子邮箱</th>
                </tr>
            </thead>
            <s:iterator value="#request.contactList" status="st" id="contactList">
             <tr>
                <td>
            		<s:checkbox name="chks" id="%{'chk'+#st.getIndex()}" fieldValue="%{contactId}" cssStyle="width:30px;border:0" theme="simple" />
				</td>
                <td>
                	<a href="contact!showContactInfo?contactId=<s:property value='contactId'/>">
                		<s:property value="contactName" default=""/>
                	</a>
                </td>
                <td>
                	<s:property value="contactIdcard" default=""/>
                </td>
                <td>
                	<s:property value="contactPhone" default=""/>
                </td>
                <td>
                	<s:property value="contacttele" default="" />
                </td>
                <td>
                	<s:property value="contactfax" default="" />
                </td>
                <td>
                	<s:date name="contactBornDate" format="yyyy-MM-dd" />
                </td>
                <td>
                	<s:property value="contactemail" default="" />
                </td>
             </tr>
            </s:iterator>
            </table>
            </div>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</body>
</html>
